<?
require_once "../include/opendb.php";
require_once "../class/CA_query.class.php";
$q = new CA_query($link);
extract($_POST, EXTR_OVERWRITE);

//clear old data
$sql = "DELETE FROM role_module WHERE role_id <> 1";
$q->qq($sql);

if(isset($rm)){
	foreach($rm AS $module_id => $item){
		if(isset($item)){
			foreach($item AS $role_id => $item){
				$data = array("role_id" => $role_id, "module_id" => $module_id);
				$q->insert("role_module", $data);
			}
		}
	}
}
$html = "1";
header("Content-type: text/html; charset=utf-8");
echo $html;

?>